package com.tms.config;

import com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceBuilder;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;

import javax.sql.DataSource;


/**
 * 多数据源配置类
 */
@Configuration
public class DataSourceConfig {

    /**
     * 本地数据源
     */
    @Primary
    @Bean
    @ConfigurationProperties("spring.datasource.develop")
    DataSource dsDevelop() {
        return DruidDataSourceBuilder.create().build();
    }

    /**
     * 线上数据源
     */
    @Bean
    @ConfigurationProperties("spring.datasource.staff")
    DataSource dsStaff() {
        return DruidDataSourceBuilder.create().build();
    }
}
